package cn.wolfcode.service.impl;

import cn.wolfcode.domain.MessageReplyZal;
import cn.wolfcode.mapper.MessageReplyZalMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMessageReplyZalService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageReplyZalServiceImpl implements IMessageReplyZalService {

    @Autowired
    private MessageReplyZalMapper messageReplyZalMapper;


    @Override
    public void save(MessageReplyZal messageReplyZal) {
        messageReplyZalMapper.insert(messageReplyZal);
    }

    @Override
    public void delete(Long id) {
        messageReplyZalMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(MessageReplyZal messageReplyZal) {
        messageReplyZalMapper.updateByPrimaryKey(messageReplyZal);
    }

    @Override
    public MessageReplyZal get(Long id) {
        return messageReplyZalMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<MessageReplyZal> listAll() {
        return messageReplyZalMapper.selectAll();
    }

    @Override
    public PageInfo<MessageReplyZal> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<MessageReplyZal> messageReplyZals = messageReplyZalMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<MessageReplyZal>(messageReplyZals);
    }

    @Override
    public List<MessageReplyZal> selectByMessageReplyId(Long messageBoardZalId) {
        List<MessageReplyZal> list = messageReplyZalMapper.selectByMessageReplyId(messageBoardZalId);
        return list;
    }
}
